import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        Student student1 = new Student("bit",10);
        Student student2 = new Student("whw",20);
        Student student3 = new Student("abc",5);

        Student[] students = new Student[3];
        students[0] = student1;
        students[1] = student2;
        students[2] = student3;

        System.out.println("排序前"+ Arrays.toString(students));

        Arrays.sort(students);

        System.out.println("排序后" + Arrays.toString(students)) ;
    }


    public static void main1(String[] args) {
        Student student1 = new Student("bit",10);
        Student student2 = new Student("whw",20);

        if (student1.compareTo(student2)>0){
            System.out.println("student1>student2");
        } else if (student1.compareTo(student2) == 0) {
            System.out.println("student < student2");
        }else{
            System.out.println("student = student");
        }

        System.out.println("=================");

        NameComparator nameComparator = new NameComparator();

        int ret = nameComparator.compare(student1,student2);
        //comapar方法中返回值为整形
        if (ret > 0){
            System.out.println("student1 > student2");
        } else if (ret <= 0) {
            System.out.println("student1 <= student2");
        }

        System.out.println("====================");
        Agecomparator agecomparator = new Agecomparator();
        int ret2 = agecomparator.compare(student1,student2);
        if (ret2  > 0){
            System.out.println("student1 > student2");
        } else if (ret2 <= 0) {
            System.out.println("student1 <= student2");
        }
    }
}
